Expand description
A simple event-driven library for parsing WebAssembly binary files (or streams).
The parser library reports events as they happen and only stores parsing information for a brief period of time, making it very fast and memory-efficient. The event-driven model, however, has some drawbacks. If you need random access to the entire WebAssembly data-structure, this is not the right library for you. You could however, build such a data-structure using this library.
To get started, create a Parser
using Parser::new
and then follow
the examples documented for Parser::parse
or Parser::parse_all
.
Modules§
- collections
validate
Type definitions for maps and sets used by thewasmparser
crate. - names
validate
Definitions of name-related helpers and newtypes, primarily for the component model. - types
validate
Types relating to type information provided by validation.
Macros§
- A helper macro to conveniently iterate over all opcodes recognized by this crate. This can be used to work with either the
Operator
enumeration or theVisitOperator
trait if your use case uniformly handles all operators the same way.
Structs§
- Represents a type of an array in a WebAssembly module.
- A binary reader of the WebAssembly structures and types.
- A binary reader for WebAssembly modules.
- A br_table entries representation.
- A hint for a single branch.
- Branch hints for a single function.
- Represents COMDAT data in the linking custom section.
- Represents a symbol that is part of a comdat.
- Represents an export in a WebAssembly component.
- Represents the name of a component export.
- Represents a type of a function in a WebAssembly component.
- Represents an import in a WebAssembly component
- Represents the name of a component import.
- Represents an argument to instantiating a WebAssembly component.
- Represents the start function in a WebAssembly component.
- Represents a composite type in a WebAssembly module.
- Represents an initialization expression.
- Represents a type of a continuation in a WebAssembly module.
- A single instance from a coredump instances section
- A custom section representing the instances involved in a given coredump
- The data portion of a “coremodules” custom section. This contains a vec of module names that will be referenced by index by other coredump sections.
- The data portion of a custom section representing a core dump. Per the tool-conventions repo, this section just specifies the executable name that the core dump came from while the rest of the core dump information is contained in a corestack custom section
- A single stack frame from a core dump
- The data portion of a custom section representing a core dump stack. The structure of this follows the coredump spec in the tool-conventions repo
- A reader for custom sections of a WebAssembly module.
- Represents a data segment in a core WebAssembly module.
- Represents the metadata about a data symbol defined in the wasm file.
- Represents a core WebAssembly element segment.
- Represents an export in a WebAssembly module.
- Represents a field type of an array or a struct.
- Frame
validate
A Wasm control flow block on the control flow stack during Wasm validation. - Func
ToValidate validate
Resources necessary to perform validation of a function. - Represents a type of a function in a WebAssembly module.
- Func
Validator validate
Validation context for a WebAssembly function. - Func
Validator Allocations validate
External handle to the internal allocations used during function validation. - Represents a WebAssembly function body.
- Represents a core WebAssembly global.
- Represents a global’s type.
- An IEEE binary32 immediate floating point value, represented as a u32 containing the bit pattern.
- An IEEE binary64 immediate floating point value, represented as a u64 containing the bit pattern.
- Represents an import in a WebAssembly module.
- Represents an indirect name in the names custom section.
- Represents an init function in the linking custom section.
- Represents an argument to instantiating a WebAssembly module.
- A reader for the
linking
custom section of a WebAssembly module. - An iterator over locals in a function body.
- A reader for a function body’s locals.
- Represents a memory immediate in a WebAssembly memory instruction.
- Represents a
WASM_DYLINK_MEM_INFO
field - Represents a memory’s type.
- Represents a name for an index from the names section.
- An iterator over a function’s operators.
- An iterator over a function’s operators with offsets.
- A reader for a core WebAssembly function’s operators.
- A packed representation of a type index.
- An incremental parser of a binary WebAssembly module or component.
- A field from the producers custom section.
- Represents a field value in the producers custom section.
- Represents a recursive type group in a WebAssembly module.
- A reference type.
- Reader for reloc.* sections as defined by https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md#relocation-sections.
- Single relocation entry within a
reloc.*
section, as defined at https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md#relocation-sections. - A representation of dispatch tables on
resume
andresume_throw
instructions. - A generic structure for reading a section of a WebAssembly binary which has a limited number of items within it.
- A consuming iterator of a
SectionLimited
. - An iterator over a limited section iterator.
- Represents extra metadata about the data segments.
- Flags for WebAssembly segments.
- Represents a type of a struct in a WebAssembly module.
- Represents a subtype of possible other types in a WebAssembly module.
- Iterator/reader over the contents of a section which is composed of subsections.
- Flags for WebAssembly symbols.
- Type information about a table defined in the table section of a WebAssembly module.
- Represents a table’s type.
- A tag’s type.
- A
try_table
entries representation. - Represents a 128-bit vector value.
- Validator
validate
Validator for a WebAssembly binary module or component. - Validator
Id validate
A unique identifier for a particularValidator
. - Validator
Resources validate
The implementation ofWasmModuleResources
used byValidator
. - Represents a case in a variant type.
- Flags for features that are enabled for validation.
- Wasm
Features Inflated features
Inflated version ofWasmFeatures
that allows for exhaustive matching on fields.
Enums§
- An abstract heap type.
- Represents a block type.
- Represents a canonical function in a WebAssembly component.
- Represents options for component functions.
- Catch clauses that can be specified in
TryTable
. - A successful return payload from
Parser::parse
. - Represents a symbol kind.
- Represents an alias in a WebAssembly component.
- Represents a defined type in a WebAssembly component.
- Represents the kind of an external items of a WebAssembly component.
- Represents the result type of a component function.
- Represents an instance in a WebAssembly component.
- Represents a name read from the names custom section.
- Represents the kind of an outer alias in a WebAssembly component.
- Represents a type in a WebAssembly component.
- Represents part of a component type declaration in a WebAssembly component.
- Represents a reference to a component type.
- Represents a value type in a WebAssembly component.
- A
CompositeType
can contain one of these types. - Local and stack values are encoded using one byte for the type (similar to Wasm’s Number Types) followed by bytes representing the actual value See the tool-conventions repo for more details.
- Represents a core type in a WebAssembly component.
- The kind of data segment.
- Possible subsections of the
dylink.0
custom section. - Represents the items of an element segment.
- The kind of element segment.
- The supported encoding formats for the parser.
- External types as defined here.
- The kind of a control flow [
Frame
]. - Handle clauses that can be specified in
ResumeTable
. - A heap type.
- Represents an instance of a WebAssembly module.
- Represents an instance type declaration in a WebAssembly component.
- Represents the kind of an instantiation argument for a core instance.
- Return value of
CustomSectionReader::as_known
. - Represents a subsection read from the linking custom section.
- Represents a module type declaration in a WebAssembly component.
- Represents a name read from the names custom section.
- Instructions as defined here.
- Represents the memory ordering for atomic instructions.
- Represents the kind of an outer core alias in a WebAssembly component.
- Values that can be parsed from a WebAssembly module or component.
- Represents a primitive value type.
- Indicates the kind of addend that applies to a relocation entry.
- Relocation entry type. Each entry type corresponds to one of the
R_WASM_*
constants defined at https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/WasmRelocs.def and https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md#relocation-sections. - Represents storage types introduced in the GC spec for array and struct fields.
- Represents extra information about symbols in the linking custom section.
- Different modes of initializing a table.
- Represents a tag kind.
- Represents the type bounds for imports and exports.
- Represents a reference to a type definition in a WebAssembly module.
- The uncompressed form of a
PackedIndex
. - Represents the types of values in a WebAssembly module.
- Valid
Payload validate
Possible return values fromValidator::payload
.
Traits§
- A trait implemented for items that can be decoded directly from a
BinaryReader
, or that which can be parsed from the WebAssembly binary format. - To compute the arity (param and result counts) of “variable-arity” operators, the operator_arity macro needs information about the module’s types and the current control stack. The ModuleArity trait exposes this information.
- A trait implemented for subsections of another outer section.
- Trait implemented by types that can visit all
Operator
variants. - Wasm
Module Resources validate
Types that qualify as Wasm validation database.
Functions§
- validate
validate
Test whether the given buffer contains a valid WebAssembly module or component, analogous toWebAssembly.validate
in the JS API.
Type Aliases§
- A reader for the
metadata.code.branch_hint
custom section. - A reader for the code section of a WebAssembly module.
- Represents a reader for COMDAT data from the linking custom section.
- Section reader for the component alias section
- A reader for the canonical section of a WebAssembly component.
- A reader for the export section of a WebAssembly component.
- A reader for the import section of a WebAssembly component.
- A reader for the component instance section of a WebAssembly component.
- Type used to iterate and parse the contents of the
component-name
custom section in compnents, similar to thename
section of core modules. - A reader for the type section of a WebAssembly component.
- A reader for the core type section of a WebAssembly component.
- A reader for the data section of a WebAssembly module.
- Parser for the dynamic linking
dylink.0
custom section. - A reader for the element section of a WebAssembly module.
- A reader for the export section of a WebAssembly module.
- A reader for the function section of a WebAssembly module.
- A reader for the global section of a WebAssembly module.
- A reader for the import section of a WebAssembly module.
- Represents a reader for indirect names from the names custom section.
- Represents a reader for init functions from the linking custom section.
- A reader for the core instance section of a WebAssembly component.
- A reader for the memory section of a WebAssembly module.
- Represents a name map from the names custom section.
- A reader for the name custom section of a WebAssembly module.
- A reader for the producers custom section of a WebAssembly module.
- Reader for relocation entries within a
reloc.*
section. - The result for
BinaryReader
operations. - Represents a reader for segments from the linking custom section.
- Represents a reader for symbol info from the linking custom section.
- A reader for the table section of a WebAssembly module.
- A reader for the tags section of a WebAssembly module.
- A reader for the type section of a WebAssembly module.